package com.demo.bootmystarter.autoconfiguration;

import com.demo.bootmystarter.format.FormatProcessor;
import com.demo.bootmystarter.format.JsonFprmatProcess;
import com.demo.bootmystarter.format.StringFormatProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class FromatConfiguration {
    @Bean
    @Primary
    @ConditionalOnMissingClass("com.alibaba.fastjson.JSON")
    public FormatProcessor stringFormat() {

        return new StringFormatProcessor();
    }

    @Bean
    @ConditionalOnClass(name = "com.alibaba.fastjson.JSON")
    public FormatProcessor jsonFormat() {

        return new JsonFprmatProcess();
    }

}
